﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta charset="UTF-8">
    <title>登录页</title>
    <meta name="page-view-size" content="1280*720">
    <link rel="stylesheet" href="./css/base.css">
		<link rel="stylesheet" href="./css/login.css">
		<script type="text/javascript" src="./lib/js/evm.js"></script>
		<script type="text/javascript" src="./lib/js/Evm_djyw.js"></script>
		<script type="text/javascript" src="./lib/js/key.js"></script>
		<script src="lib/js/md5.js" type="text/javascript" charset="utf-8"></script>
		<script src="lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/api.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
    <div class="login-bg">
        <div class="login-img">
            <img id="loginImg" src="" alt="">
        </div>
        <div class="login-msg">
            请扫码登录
        </div>
    </div>
</body>
<script>
    var random = parseInt(Math.random() * 10000);
		console.info(random);
		var scankey = hex_md5(navigator.userAgent + random);
		var surl = API_URL.loginURL + "home/index/qrcode?url=" + API_URL.WXUrl + "home/auth/qrcodelogin?scankey=" + scankey;
		$("#loginImg").attr("src", surl);
		//		TV.PromptMsg(EVM.cookie.getValue('TV_CST_TOKEN'));
		window.setInterval(function() {
			var params = {
				scankey: scankey,
				// cardNo: 666 || ''
			}
			console.log('run')
			http(API_URL.loginURL + 'home/auth/getQrcodeLoginToken', params, function(err, data) {
			// http(API_URL.loginURL + 'home/auth/getQrcodeLoginToken', params, function(err, data) {

				console.log(data)
				
				if(data.code == 0) {
					
					$(".login-msg").html("登陆成功");
					console.log(data.data.access_token,'--------------------------')
					EVM.cookie.setValue('TV_CST_TOKEN', data.data.access_token)
					var mess = {
						access_token: data.data.access_token
					}
					var res = {
						//cardno: hardware.STB.serialNumber || '',
						access_token: data.data.access_token
					}
					http(API_URL.loginURL + 'home/auth/bindCardNo', res, function(err, data) {

					})
					http(API_URL.loginURL + 'api/user/getProfile', mess, function(err, data) {
						console.table(data.data)
						// if(){
							
						// }
						var moblie = data.data.is_bind_mobile || null;
						EVM.cookie.setValue('TV_CST_NAME', data.data.nickname)
						EVM.cookie.setValue('TV_CST_HEADIMG', API_URL.WXHeadimg+data.data.avatar.replace('http://thirdwx.qlogo.cn',''))
						EVM.cookie.setValue('TV_CST_MOBILE', moblie)
						EVM.cookie.setValue('shit', "张学友.jpg")
						TV.UserMess();

						window.history.go(-1)
					})

				} else if(data.code == 903) {
					$(".login-msg").html("已扫描");
				}
			})
		}, 3000);
</script>
<script src="js/login.js"></script>

</html>